var t = (0, require("../../../@babel/runtime/helpers/interopRequireDefault").default)(require("../../../utils/util")),
  a = new(require("../../../utils/http").HTTP);
Page({
  data: {
    taga: [{
      id: 0,
      name: "全年"
    }, {
      id: 1,
      name: "1月"
    }, {
      id: 2,
      name: "2月"
    }, {
      id: 3,
      name: "3月"
    }, {
      id: 4,
      name: "4月"
    }, {
      id: 5,
      name: "5月"
    }, {
      id: 6,
      name: "6月"
    }, {
      id: 7,
      name: "7月"
    }, {
      id: 8,
      name: "8月"
    }, {
      id: 9,
      name: "9月"
    }, {
      id: 10,
      name: "10月"
    }, {
      id: 11,
      name: "11月"
    }, {
      id: 12,
      name: "12月"
    }]
  },
  onLoad: function (e) {
    var n = this;
    n.setData({
        id: e.id
      }),
      1 == e.id ? (wx.setNavigationBarTitle({
        title: "载体统计"
      }), a.request({
        url: "https://www.qlsyyun.com:3000/lease/census"
      }).then((function (t) {
        n.setData({
          carrier: t.data
        })
      })), a.request({
        url: "https://www.qlsyyun.com:3000/lease/total"
      }).then((function (t) {
        n.setData({
          carriers: t.data
        })
      }))) : 2 == e.id ? (wx.setNavigationBarTitle({
        title: "去化统计"
      }), a.request({
        url: "https://www.qlsyyun.com:3030/rent/list",
        data: {
          arr: 1,
          month: t.default.formatDates(new Date)
        }
      }).then((function (t) {
        for (var a = t.data, e = a.map((function (t) {
            return t.rza
          })), r = 0, i = 0; i < e.length; i++)
          r += e[i];
        for (var u = a.map((function (t) {
            return t.rzb
          })), o = 0, s = 0; s < u.length; s++)
          o += u[s];
        n.setData({
          hire: t.data,
          currentItem: t.data[0].yf,
          sum: r,
          total: o
        })
      }))) : (wx.setNavigationBarTitle({
        title: "退租统计"
      }), a.request({
        url: "https://www.qlsyyun.com:3030/rent/list",
        data: {
          arr: 3,
          month: t.default.formatDates(new Date)
        }
      }).then((function (t) {
        for (var a = t.data, e = a.map((function (t) {
            return t.tza
          })), r = 0, i = 0; i < e.length; i++)
          r += e[i];
        for (var u = a.map((function (t) {
            return t.tzb
          })), o = 0, s = 0; s < u.length; s++)
          o += u[s];
        n.setData({
          tuizu: t.data,
          currentItem: t.data[0].yf,
          sum: r,
          total: o
        })
      })))
  },
  tagChoose: function (t) {
    var e = this,
      n = t.currentTarget.dataset.id;
    if (e.setData({
        currentItem: n
      }), 2 == e.data.id)
      if (0 == n) {
        var r = this;
        a.request({
          url: "https://www.qlsyyun.com:3030/rent/list",
          data: {
            arr: 2
          }
        }).then((function (t) {
          if (0 == t.data.length)
            wx.showToast({
              title: "暂无本年度数据",
              icon: "none",
              duration: 1e3
            });
          else {
            for (var a = t.data, e = a.map((function (t) {
                return t.rza
              })), n = 0, i = 0; i < e.length; i++)
              n += e[i];
            for (var u = a.map((function (t) {
                return t.rzb
              })), o = 0, s = 0; s < u.length; s++)
              o += u[s];
            r.setData({
              hire: t.data,
              sum: n.toFixed(2),
              total: o
            })
          }
        }))
      } else
        a.request({
          url: "https://www.qlsyyun.com:3030/rent/list",
          data: {
            arr: 1,
            month: n
          }
        }).then((function (t) {
          if (0 == t.data.length)
            wx.showToast({
              title: "暂无该月数据",
              icon: "none",
              duration: 1e3
            });
          else {
            for (var a = t.data, n = a.map((function (t) {
                return t.rza
              })), r = 0, i = 0; i < n.length; i++)
              r += n[i];
            for (var u = a.map((function (t) {
                return t.rzb
              })), o = 0, s = 0; s < u.length; s++)
              o += u[s];
            e.setData({
              hire: t.data,
              currentItem: t.data[0].yf,
              sum: r,
              total: o
            })
          }
        }));
    else if (0 == n) {
      var i = this;
      a.request({
        url: "https://www.qlsyyun.com:3030/rent/list",
        data: {
          arr: 4
        }
      }).then((function (t) {
        if (0 == t.data.length)
          wx.showToast({
            title: "暂无该月数据",
            icon: "none",
            duration: 1e3
          });
        else {
          for (var a = t.data, e = a.map((function (t) {
              return t.tza
            })), n = 0, r = 0; r < e.length; r++)
            n += e[r];
          for (var u = a.map((function (t) {
              return t.tzb
            })), o = 0, s = 0; s < u.length; s++)
            o += u[s];
          i.setData({
            tuizu: t.data,
            currentItem: t.data[0].yf,
            sum: n,
            total: o
          })
        }
      }))
    } else
      a.request({
        url: "https://www.qlsyyun.com:3030/rent/list",
        data: {
          arr: 3,
          month: n
        }
      }).then((function (t) {
        if (0 == t.data.length)
          wx.showToast({
            title: "暂无该月数据",
            icon: "none",
            duration: 1e3
          });
        else {
          for (var a = t.data, n = a.map((function (t) {
              return t.tza
            })), r = 0, i = 0; i < n.length; i++)
            r += n[i];
          for (var u = a.map((function (t) {
              return t.tzb
            })), o = 0, s = 0; s < u.length; s++)
            o += u[s];
          e.setData({
            tuizu: t.data,
            currentItem: t.data[0].yf,
            sum: r,
            total: o
          })
        }
      }))
  }
});